package com.library.recommendBook.service;

import com.library.entity.*;
import com.library.recommendBook.dao.RecommendBookDaoImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(readOnly=false)
public class RecommendBookServiceImpl {
	
	@Resource
	private RecommendBookDaoImpl recommendBookDaoImpl;

	public void addRecommendBook(RecommendBook recommendBook){
		this.recommendBookDaoImpl.saveRecommendBook(recommendBook);
	}

    @Transactional(readOnly=true)
	public RecommendBook getRecommendBookById(Integer recommendBookId)
	{
		return this.recommendBookDaoImpl.getRecommendBookById(recommendBookId);
	}

	public void updateRecommendBook(RecommendBook recommendBook){
		this.recommendBookDaoImpl.updateRecommendBook(recommendBook);
	}

    @Transactional(readOnly=true)
	/*查找全部推荐图书*/
	public List<RecommendBook> getAllRecommendBook()
	{
		return this.recommendBookDaoImpl.getAll();
	}

	/*删除指定评价记录*/
	public void deleteRecommendBook(int recommendBookId){
		RecommendBook recommendBook = this.getRecommendBookById(recommendBookId);

		this.recommendBookDaoImpl.deleteRecommendBook(recommendBook);
    }
}
